#pragma once

#include "Includes.h"

class Handle {
public:
	Handle(HANDLE handle);

	HANDLE getHandle();

	operator HANDLE();

private:
	// The HandleHolder OWNS the underlying handle. After the HandleHolder is destroyed the Handle will be closed.
	struct HandleHolder {
		HandleHolder(HANDLE handle) : mHandle(handle) {}
		~HandleHolder() { CloseHandle(mHandle);}
		HANDLE mHandle;
	};

	std::shared_ptr<HandleHolder> mHandleHolder;
};